function wyslijDane()
{
  var tfL1Text = document.getElementById("tfL1").value;
  var tfL2Text = document.getElementById("tfL2").value;
  var btnPodziel = document.getElementById("btnPodziel");

  url = "http://localhost/dane.php?l1=" + tfL1Text;
  url += "&l2=" + tfL2Text;
  url = encodeURI(url);

  btnPodziel.disabled = true;
  startGETRequest(url, onComplete, onEnd);
}

function onComplete(text, xml)
{
  arr = text.split(":");
  var tfL1 = document.getElementById("tfL1");
  var tfL2 = document.getElementById("tfL2");

  if(arr[0] == "error"){
    if(arr.length == 4){
      if(arr[3] == "l1"){
        tekst = arr[2] + "\nKod bdu: " + arr[1];
        tfL1.style.backgroundColor = "#FFFF00";
        tfL2.style.backgroundColor = "#FFFFFF";
      }
      else if(arr[3] == "l2"){
        tekst = arr[2] + "\nKod bdu: " + arr[1];
        tfL1.style.backgroundColor = "#FFFFFF";
        tfL2.style.backgroundColor = "#FFFF00";
      }
      else{
        tekst = "Nieprawidowa odpowied serwera.";
      }
    }
    else if(arr.length == 5){
      if(arr[3] == "l1" && arr[4] == "l2"){
        tekst = arr[2] + "\nKod bdu: " + arr[1];
        tfL1.style.backgroundColor = "#FFFF00";
        tfL2.style.backgroundColor = "#FFFF00";
      }
      else{
        tekst = "Nieprawidowa odpowied serwera.";
      }
    }
    else{
      tekst = "Nieprawidowa odpowied serwera.";
    }
    alert(tekst);
  }
  else{
    tfL1.style.backgroundColor = "#FFFFFF";
    tfL2.style.backgroundColor = "#FFFFFF";

    var dataDiv = document.getElementById("dataDiv");
    dataDiv.innerHTML = text;
  }
}

function onEnd()
{
  var btnPodziel = document.getElementById("btnPodziel");
  btnPodziel.disabled = false;
}